#ifndef VL_SOCKETS_IMPL_HPP
#define VL_SOCKETS_IMPL_HPP

#include "sockets.hpp"

#if defined(WINDOWS)
#ifndef NOGDI
#define NOGDI
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif

/*
#ifndef POINTER_64
#define POINTER_64 // Needed for bugged headers
#endif*/
#define _WIN32_WINDOWS 0x0410
#define WINVER 0x0410
#include <winsock2.h>
#include <cstdlib>

#ifdef _MSC_VER
#pragma comment(lib, "ws2_32.lib")
#endif

namespace vl
{

inline SOCKET native_socket(socket s)
{
	return (SOCKET)s._voidp;
}

inline socket make_socket(SOCKET _native)
{
	socket s;
	s._voidp = (void*)_native;
	return s;
}

typedef int socklen_t;


}

#else //if !defined(OSK)

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>


namespace vl
{

inline int native_socket(socket s)
{
	return s._int;
}

inline socket make_socket(int _native)
{
	socket s;
	s._int = _native;
	return s;
}


}

#endif

namespace vl
{

struct host_entry : public hostent
{
	host_entry(hostent const* p);
	
	~host_entry();
};

struct internet_sockaddr : public sockaddr_in
{
	sockaddr* get_sockaddr();
};

}


#endif // VL_SOCKETS_IMPL_HPP
